home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 11, No. 03 (1990-03)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 11, No. 03 (1990-03)(MindCraft Publishing)(Side A).po
/
DISK.DOCTOR.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
45KB
|
1,420 lines
*****************************************
* *
* DISK.DOCTOR SOURCE CODE *
* BY MICHAEL E. ANDERSON *
* COPYRIGHT(C) 1990 *
* MINDCRAFT PUBL. CORP. *
* CONCORD, MA 01742 *
* *
*****************************************
* *
* MERLIN ASSEMBLER *
* *
*****************************************
ORG $A10 ;origin
JMP START ;program entry point
* Global Equates ---------------------------------------*
RIGHT EQU $21 ;right margin
TOP EQU $22 ;top margin
BOTTOM EQU $23 ;bottom margin
HORIZ EQU $24 ;horizontal tab
VERT EQU $25 ;vertical tab
CSWL EQU $36 ;output hook low order byte
CSWH EQU $37 ;output hook high order byte
KSWL EQU $38 ;input hook low order byte
KSWH EQU $39 ;input hook high order byte
HOME EQU $FC58 ;home cursor & clear screen
PHEX EQU $FDDA ;entry pnt output hex char
PCHAR EQU $FDED ;entry pnt output ASCII char
READ1 EQU $FD0C ;keyin reads key from keyboard
MLI EQU $BF00 ;MLI entry point
BASIC EQU $03D0 ;basic entry point
TAB EQU $FC22 ;tabbing entry point
CLEOL EQU $FC9C ;clear to end of line
OUTPORT EQU $FE95 ;reset outport hooks
BBUFF EQU $0800 ;page 1 buffer
BBUFF2 EQU $0900 ;page 2 buffer
* Strings ----------------------------------------------*
STR1 ASC ' PRODOS DISK DOCTOR BY MICHAEL E. ANDERSON '
TAG ASC '(C) 1990 MINDCRAFT PUBL. CORP. ',8D
ASC " [N],[W],[C],[E],[L],[P],[R],"
ASC "[Q],[A]ssist -- ENTER COMMAND :",00
STR2 ASC "ASCII-EQUIV. "
STR2A ASC "BLOCK",3D
DB $00
STR3 ASC "Enter Drive (1 or 2)________________$",00
ASC "Enter Slot (1 -- 7)________________$",00
ASC "Enter Base Block ($0000 thru $FFFF)_$",00
ERR_MSG1 DDB $8D8D
ASC "I/O ERROR",00
ERR_MSG2 DDB $8D8D
ASC "NO DEVICE CONNECTED",00
TRY_MSG DDB $8D8D
ASC "TRY AGAIN (Y or N):",00
VMSG1 ASC "VERIFY WRITE (Y or N):",00
ED_MSG1 ASC "[A]SCII or [H]EX :"
BLK_MSG ASC "BLOCK"
HLP_MSG DB $8D
ASC "[N]ext Block ------------ Retrieves the "
ASC "next block from disk",8D
ASC "[W]rite Block ----------- Writes the cur"
ASC "rent block to disk",8D
ASC "[C]hange Page ----------- Displays the "
ASC "opposite half of the current block",8D
DB $00
HLP_MSG1 ASC "[E]dit ------------------ Allows editing "
ASC "current block in AS"
ASC "CII or HEX",8D
ASC "[L]ast Block ------------ Retrieves the "
ASC "previous block from disk",8D
ASC "[P]rint Block ----------- Prints the "
ASC "current block to the Printer (slot 1)",8D
DB $00
HLP_MSG2 ASC "[R]eset Base ------------ Allows you to "
ASC "retrieve a block at random",8D
ASC "[Q]uit ------------------ Exits the prog"
ASC "ram",8D
ASC "[A]ssist ---------------- Displays this"
ASC " screen",8D
ASC "<ESC>________ Exits Current Prompt retur"
ASC "ns to command line",8D
DB $00
HLP_MSG3 ASC "<SPC>________ Changes High Low Nibble by"
ASC "te position in EDIT Mode",8D
ASC "<ARROW'S>____ Moves Cursor within HEX or"
ASC " ASCII grid during EDIT",8D
DB $8D
ASC " PRESS ANY KEY:"
DB $00
QT_MSG ASC "Exit Program (Y or N) :",00
PG_MSG ASC "Page"
PRNT_MSG ASC "Printer Ready (Y or N):"
* Temp Storage -----------------------------------------*
NUM DB $00 ;count byte for LINE routine
PNTR1 DB $00 ;temp char pointer
PNTR2 DB $00 ;temp counter
TEMPA DB $00 ;temp 'A' reg.
TEMPA2 DB $00 ;secondary temp 'A' reg.
TEMPY DB $00 ;temp 'Y' reg.
FIRST DB $00 ;high nibble of high order word
SECOND DB $00 ;low nibble of high order word
THIRD DB $00 ;high nibble of low order word
FOURTH DB $00 ;low nibble of low order word
PAGE DB $00 ;page index
BPNTR DB $00 ;base pointer line
EBASE DB $00 ;16 bytes per count
CUR_BYTE DB $00 ;current byte pos.(htab)
BYTE_POS DB $00 ;nibble index
CUR_LINE DB $00 ;line of bytes (vtab)
BYTE_NO DB $00 ;buffer index
TMP_BYTE DB $00 ;temp byte storage
HEX_POS DB $00 ;current hex grid position
ASK_POS DB $00 ;current ascii grid position
CSWLS DB $00 ;output hooks temp
CSWHS DB $00
KSWLS DB $00 ;input hooks temp
KSWHS DB $00
PAGE_TMP DB $00 ;temp page index
* File Control Block -----------------------------------*
FCB DB $03 ;parameter count
DEV_NUM DB $00 ;device number
DA BBUFF ;buffer addr.
BLK_LOW DB $00 ;block number low byte
BLK_HIGH DB $00 ;block number high byte
* Program Entry Point ----------------------------------*
START JSR SCREEN ;set up main screen
JSR DEVICE ;get device information
JSR DISP_BLK ;display block
JMP COM_LINE ;command line entry
* Screen Format Routine --------------------------------*
SCREEN LDA #$03 ;slot #
JSR $FE95 ;set I/O hooks for 80 col.
ST LDA #$00
STA TOP ;set top margin
STA VERT ;set vert.tab var.
JSR HOME ;clear screen
LDA #$00
STA HORIZ ;set horiz.tab var.
JSR TAB ;pos. using vert & horiz
LDY #00 ;set base pntr
LOOP1 LDA STR1,Y ;string
CMP #00 ;string terminate
BEQ NXT1
JSR PCHAR ;char.output
INY ;bump pntr.
JMP LOOP1 ;get next char.
NXT1 LDA #$8D ;crlf.
JSR PCHAR ;char.output
JSR PCHAR
LDY #00 ;set base pntr.
PG1 LDA PG_MSG,Y ;string
JSR PCHAR ;char.output
CPY #$03 ;string terminate
BEQ PG2
INY ;bump pntr.
JMP PG1 ;get next char.
PG2 LDA #$3D ;'='
JSR PCHAR ;char.output
LDX #$00 ;char.for indx.header
LOOP3 LDA #$FC ;"|"
JSR PCHAR ;char.output
TXA ;get indx.
JSR PHEX ;hex.output
INX ;bump indx.
CPX #$10
BEQ NXT3 ;end of routine
JMP LOOP3 ;print next indx.
NXT3 LDA #$FC ;"|"
JSR PCHAR ;char.output
LDA #$05 ;#of'='s for line
STA NUM
JSR LINE ;print line (======)
LDY #00 ;set base pntr.
LOOP5 LDA STR2,Y ;string
CMP #$A0 ;string terminate
BEQ NXT5
JSR PCHAR ;char.output
INY ;bump pntr.
JMP LOOP5 ;get next char.
NXT5 LDA #$03 ;#of'='s for line
STA NUM
JSR LINE ;print line (======)
LDY #$00 ;set base pntr.
LOOP6 LDA STR2A,Y ;string
CMP #$00 ;string terminate
BEQ NXT5A
JSR PCHAR ;char.output
INY ;bump pntr.
JMP LOOP6 ;get next char.
NXT5A LDA #$50 ;#of'='s for line
STA NUM
JSR LINE ;print line (======)
LDA #$05
STA TOP ;set top margin
LDA #$15
STA VERT ;set vert.tab var.
LDA #$00
STA HORIZ ;set horiz.tab var
JSR TAB ;pos.using vert.& horiz.
LDA #$50 ;#of'='s for line
STA NUM
JSR LINE ;print line (======)
LDA #$15
STA BOTTOM ;set bot.margin
RTS ;return to caller
* Window Definition ------------------------------------*
WIND LDA #$06
STA VERT ;set vert.tab var.
STA HORIZ ;set horiz.tab var.
JSR TAB ;pos.using vert.& horiz.
LDA #$05
STA TOP ;set top.margin
LDA #$15
STA BOTTOM ;set bot.margin
LDA #$4B
STA RIGHT ;set right margin
RTS ;return to caller
* Set Prompts For Device Info --------------------------*
* All reg.'s at this point are free --------------------*
DEVICE JSR WIND ;pos.curs.set wnd.
LDX #$00 ;set base pntr.
LDA #$00 ;null pntrs.
D0 STA PNTR1,X ;pntr.bufr.
CPX #$10
BEQ DEV ;get dev.info.
INX ;bump pntr.
JMP D0 ;null next pntr.
DEV JSR HOME ;clear screen
D1 LDA #$8D ;crlf.
JSR PCHAR ;char.output
LDY PNTR1 ;prompt flag
D2 LDA STR3,Y ;string
INY ;bump pntr
CMP #$00 ;char.terminate
BEQ GETIN
JSR PCHAR ;char.output
JMP D2 ;get next char.
GETIN STY PNTR1 ;store prompt flag
LDY PNTR2 ;loop cntr.
INY
STY PNTR2 ;save loop cntr.
JSR INPUT1
LDY PNTR2 ;loop cntr.
CPY #$03 ;chk for 3 times thru loop
BEQ NXT6
JMP D1
NXT6 CLC ;carry used for error chk
LDA #$80 ;read_block param.
STA R_W ;read/write byte
JMP MLI_E ;MLI entry point
* Command Line -----------------------------------------*
COM_LINE LDA #$44
STA HORIZ ;horiz.tab var.
LDA #$01
STA VERT ;vert.tab var.
JSR TAB ;pos.using vert.& horiz.
JSR READ1 ;read keyboard
JSR PROCOM ;process command
JMP COM_LINE ;return to command line
* Process Command --------------------------------------*
PROCOM CMP #$8E ;cntrl-N
BEQ NBLK
CMP #$91 ;cntrl-Q
BEQ QBLK
CMP #$83 ;cntrl-C
BEQ CP
CMP #$8C ;cntrl-L
BEQ LBLK
CMP #$92 ;cntrl-R
BEQ RBASE
CMP #$97 ;cntrl-W
BEQ WRTE
CMP #$90 ;cntrl-P
BEQ PRNT
CMP #$85 ;cntrl-E
BEQ EDIT
CMP #$81 ;cntrl-A
BEQ HLP
RTS ;return to command line
NBLK JSR NBLKA ;get next block
RTS ;return to command line
QBLK JSR QT ;exit program enter basic
RTS
CP JSR CHPAGE ;change page
RTS ;return to command line
LBLK JSR LSTBLK ;get previous block
RTS ;return to command line
RBASE JSR RBAS ;reset the base block
RTS ;return to command line
WRTE JSR RITE ;setup for write block
RTS ;return to command line
PRNT JSR PRNTT ;go print block
RTS ;return to command line
EDIT JSR EDIT1A ;edit current block
RTS ;return to command line
HLP JSR HELP ;display help screen
RTS ;return to command line
* Help Screen ------------------------------------------*
HELP JSR WIND ;pos.curs. set wndw.
JSR HOME ;clear screen
LDX #$00 ;set base pntr.
HLP1 LDA HLP_MSG,X ;string
CMP #$00 ;sting terminate
BEQ HLP2
INX ;bump pntr.
JSR PCHAR ;char.output
JMP HLP1 ;get next char.
HLP2 LDX #$00 ;set base pntr.
HLP3 LDA HLP_MSG1,X ;string
CMP #$00 ;string terminate
BEQ HLP4
INX ;bump pntr.
JSR PCHAR ;char.output
JMP HLP3 ;get next char.
HLP4 LDX #$00 ;set base pntr.
HLP5 LDA HLP_MSG2,X ;string
CMP #$00 ;string terminate
BEQ HLP6
INX ;bump pntr.
JSR PCHAR ;char.output
JMP HLP5 ;get next char.
HLP6 LDX #$00 ;set base pntr.
HLP6A LDA HLP_MSG3,X ;string
CMP #$00 ;string terminate
BEQ HLP7
INX ;bump pntr.
JSR PCHAR ;char.output
JMP HLP6A ;get next char.
HLP7 JSR READ1 ;read keyboard
JSR DISP_BLK ;refreash the screen
RTS ;return to caller
* Edit ASCII or HEX ------------------------------------*
EDIT1A LDA #$16
STA VERT ;set vert.tab var.
LDA #$1E
STA HORIZ ;set horiz.tab var.
JSR TAB ;pos.using vet.& horiz.
LDX #$00 ;set base pntr.
ED LDA ED_MSG1,X ;string
JSR PCHAR ;char.output
CPX #$11 ;string terminate
BEQ ED1
INX ;bump pntr.
JMP ED ;get next char.
ED1 JSR READ1 ;read keyboard
CMP #$9B ;ESC
BEQ ED2
AND #$DF ;mask to upper case
CMP #$C1 ;'A'scii
BEQ ED3
CMP #$C8 ;'H'ex
BEQ ED4
JMP ED1 ;get another key
ED2 JSR CLR1 ;clear message line
RTS ;return to command line
ED3 JSR CLR1 ;clear message line
JSR ASKEY ;enter askey edit module
RTS ;return to command line
ED4 JSR CLR1 ;clear message line
JSR EDIT1 ;enter hex edit module
RTS ;return to command line
* Right Arrow for ASCII Routine ------------------------*
RAW LDX CUR_BYTE ;current htab
CPX #$48 ;end of line
BEQ RAW1
INC CUR_BYTE ;vtab by one
INC HEX_POS ;htab_pos for hex grid
INC HEX_POS ;bump it by three
INC HEX_POS
INC BYTE_NO ;bump index by one
JSR UPD_POS ;update cursor position
RTS ;return to caller
RAW1 LDX #$39 ;reset to begin line
STX CUR_BYTE ;current htab
LDA BYTE_NO ;bufr.index
SEC
SBC #$0F
STA BYTE_NO ;bufr.index
LDA #$06 ;reset tab loc. for hex grid
STA HEX_POS ;hex grid index
JSR UPD_POS ;update cursor position
RTS ;return to caller
* Left Arrow for ASCII Routine -------------------------*
LAW LDX CUR_BYTE ;current htab
CPX #$39 ;ascii grid line begin
BEQ LAW1
DEC CUR_BYTE
DEC HEX_POS ;decrement hex grid index
DEC HEX_POS ;by three
DEC HEX_POS
DEC BYTE_NO ;bufr.index
JSR UPD_POS ;update cursor position
RTS ;return to caller
LAW1 LDX #$48
STX CUR_BYTE ;update current htab
LDA BYTE_NO ;bufr.index
CLC
ADC #$0F
STA BYTE_NO ;bufr.index
LDA #$33 ;EOL hex grid
STA HEX_POS ;hex grid index
JSR UPD_POS ;update cursor position
RTS ;return to caller
* ASCII Filter -----------------------------------------*
ASKEY1 CMP #$8D ;crlf
BEQ ASKEY2
CMP #$A0 ;bottom limit of ascii range
BCC ASKEY2
CMP #$FF ;outer limit of ascii range
BCS ASKEY2
STA TMP_BYTE ;store 'A' reg.
JSR PCHAR ;char.ouput
LDA CUR_BYTE ;get current htab
STA ASK_POS ;ASCII grid index
LDA HEX_POS ;HEX grid index
STA CUR_BYTE ;set current htab
JSR UPD_POS ;update cursor
LDA TMP_BYTE ;restore 'A' reg.
AND #$7F ;set to low Ascii
JSR PHEX ;refresh hex grid
LDA ASK_POS ;ASCII grid index
STA CUR_BYTE ;set current htab
JSR UPD_POS ;update cursor
LDA PAGE ;get page index
CMP #$00 ;is it page 1
BEQ ASKEY3
LDA TMP_BYTE ;get original val of entry
AND #$7F ;set to low ascii
LDX BYTE_NO ;get buffer index
STA BBUFF2,X ;store new byte val
ASKEY2 RTS ;return to caller
ASKEY3 LDA TMP_BYTE ;get original entry
AND #$7F ;set to low ascii
LDX BYTE_NO ;get buffer index
STA BBUFF,X ;store new byte val
RTS ;return to caller
* ASCII Entry Module -----------------------------------*
ASKEY LDA #$39 ;byte 0 ascii grid
STA CUR_BYTE ;current htab
LDA #$06 ;htab for hex grid
STA HEX_POS ;store htab loc.for hex grid
LDA #$05
STA CUR_LINE ;current vtab
LDA #$00 ;set base index
STA BYTE_NO ;bufr.index
JSR UPD_POS ;update curs.
ASK1 JSR READ1 ;read keyboard
CMP #$9B ;ESC
BEQ ASK2
CMP #$81 ;Cntrl-H
BEQ ASKHLP
CMP #$95 ;right arrow
BEQ ASK3
CMP #$88 ;left arrow
BEQ ASK4
CMP #$8B ;up arrow
BEQ ASK5
CMP #$8A ;down arrow
BEQ ASK6
JSR ASKEY1 ;validate ascii range
JMP ASK1 ;loop get a key
ASK2 RTS ;return to caller
ASK3 JSR RAW ;right arrow key was pressed
JMP ASK1 ;get a key upon return
ASK4 JSR LAW ;left arrow key was pressed
JMP ASK1 ;get a key upon return
ASK5 JSR UPARROW ;up arrow key was pressed
JMP ASK1 ;get a key upon return
ASK6 JSR DNARROW ;down arrow key was pressed
JMP ASK1 ;get a key upon return
ASKHLP JSR HELP ;go display help screen
JSR UPD_POS ;update curs.pos.
JMP ASK1 ;loop get a key
* Edit Current Block -----------------------------------*
EDIT1 LDA #$05
STA CUR_LINE ;set current vtab
LDA #$06 ;htab for position 0
STA CUR_BYTE ;set current htab
LDA #$39 ;set ascii grid loc 0
STA ASK_POS ;ascii grid index
LDA #$00
STA BYTE_POS ;nibble index
STA BYTE_NO ;bufr.index
JSR UPD_POS ;update curs.pos.
EDIT2 JSR READ1 ;read keyboard
CMP #$9B ;ESC
BEQ ESC1
CMP #$81 ;Cntrl-A
BEQ EDHLP
CMP #$A0 ;space bar
BEQ SPCBA
CMP #$95 ;right arrow
BEQ RAROW
CMP #$88 ;left arrow
BEQ LAROW
CMP #$8B ;up arrow
BEQ UPAROW
CMP #$8A ;down arrow
BEQ DNAROW
JSR CHBYTE ;validate and change nibble
JMP EDIT2 ;keep looping until ESC
ESC1 RTS ;exit from editor
SPCBA JSR SPCBAR ;change position in byte
JMP EDIT2 ;loop back for another key
RAROW JSR RARROW ;bump to next byte
JMP EDIT2 ;loop back for another key
LAROW JSR LARROW ;bump back a byte
JMP EDIT2 ;loop back for another key
UPAROW JSR UPARROW ;bump up 16 bytes
JMP EDIT2 ;loop back for another key
DNAROW JSR DNARROW ;bump down 16 bytes
JMP EDIT2 ;loop back for another key
EDHLP JSR HELP ;display help screen
JSR UPD_POS ;update curs.pos.
JMP EDIT2 ;loop back for another key
* Validate and Change Nibble ---------------------------*
CHBYTE CMP #$B0 ;'0'
BCC CB5 ;out of range maybe alpha
CMP #$BA ;1 greater than ascii 9
BCS CB1 ;out of range maybe alpha
JSR DECI
RTS ;return to caller
CB1 AND #$DF ;mask to uppercase
CMP #$C1 ;'A'
BCC CB5 ;less than could be #
CMP #$C7 ;'G'
BCS CB5 ;out of range
JSR ALPHA ;is alpha go process
CB5 RTS ;return to caller
* Alpha Character --------------------------------------*
ALPHA CLC
AND #$0F ;mask off high nibble
ADC #$09 ;bring to hex equiv.
JMP ALL1
DECI AND #$0F ;mask off high nibble
ALL1 LDX BYTE_POS ;nibble index
CPX #$01 ;low nibble
BEQ LOWNIB ;is low nibble
ASL ;shift low to high nibble
ASL
ASL
ASL
LOWNIB STA TMP_BYTE ;store result
CPX #$00 ;high nibble
BEQ HN1 ;is high
DEC CUR_BYTE ;current htab
DEC BYTE_POS ;nibble index
LDX BYTE_NO ;get bufr.index
LDY PAGE ;get page index
CPY #$00 ;page 1
BEQ BUFP1 ;is page 1
LDA BBUFF2,X ;get byte from page 2
AND #$F0 ;mask off high nibble
JSR BFP ;go update byte page 2
RTS ;return to caller
BUFP1 LDA BBUFF,X ;get byte from page 1
AND #$F0 ;mask off high nibble
JSR BFP1 ;go update byte page 1
RTS ;return to caller
HN1 LDX BYTE_NO ;get buffer index
LDY PAGE ;get page index
CPY #$00 ;page 1
BEQ BUFP2 ;is page 1
LDA BBUFF2,X ;get byte from page 2
AND #$0F ;mask off low nibble
BFP CLC
ADC TMP_BYTE ;add change to byte
STA BBUFF2,X ;store result
STA TEMPA2 ;new byte val.
JSR UPD_POS ;update curs.pos.
JSR PHEX ;hex.output
JSR UPD_ASK ;update ascii grid
JSR UPD_POS ;update curs.pos
RTS ;return to caller
BUFP2 LDA BBUFF,X ;get byte from page one
AND #$0F ;mask off low nibble
BFP1 CLC
ADC TMP_BYTE ;add change to byte
STA BBUFF,X ;store result
STA TEMPA2 ;new byte val
JSR UPD_POS ;update curs.pos.
JSR PHEX ;hex.output
JSR UPD_ASK ;update ascii grid
JSR UPD_POS ;update curs.pos
RTS ;return to caller
* Update ASCII Grid ------------------------------------*
UPD_ASK LDY CUR_BYTE ;current htab
STY HEX_POS ;hex grid index
LDY ASK_POS ;ascii index
STY CUR_BYTE ;current htab
LDA TEMPA2 ;new byte val
ORA #$80 ;set to high ascii
CMP #$A0 ;low ascii range
BCC OOR
CMP #$FF ;upper ascii range
BCS OOR
JSR UPD_POS ;update curs.pos.
JSR PCHAR ;char.output
JMP UPD_D ;cleanup for return
OOR LDA #$AE ;'.'
JSR UPD_POS ;update curs.pos.
JSR PCHAR ;char.output
JMP UPD_D ;cleanup for return
UPD_D LDY HEX_POS ;get hex grid index
STY CUR_BYTE ;current htab
LDA TEMPA2 ;new byte val
RTS ;return to caller
* Move Up 16 Bytes -------------------------------------*
UPARROW JSR CH_POS ;chk to affirm high nibble
LDA CUR_LINE ;get current vtab
CMP #$05 ;top limit
BEQ UP1
LDA BYTE_NO ;bufr. index
SEC
SBC #$10 ;bump back 16 bytes
STA BYTE_NO ;new bufr.index
DEC CUR_LINE ;current vtab
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
UP1 LDA #$14 ;set to bottom limit
STA CUR_LINE ;current vtab
LDA BYTE_NO ;bufr.index
CLC
ADC #$F0 ;bump by 240 bytes
STA BYTE_NO ;bufr.index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
* Move Down 16 Bytes -----------------------------------*
DNARROW JSR CH_POS ;chk to affirm high nibble
LDA CUR_LINE ;current vtab
CMP #$14 ;bottom limit
BEQ DN1
INC CUR_LINE ;current vtab
LDA BYTE_NO ;bufr.index
CLC
ADC #$10
STA BYTE_NO ;bufr.index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
DN1 LDA #$05 ;set to top limit
STA CUR_LINE ;current vtab
LDA BYTE_NO ;bufr.index
SEC
SBC #$F0 ;bump down 240 bytes
STA BYTE_NO ;bufr.index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
* High Nibble Validity Chk -----------------------------*
CH_POS LDA BYTE_POS ;nibble index
CMP #$00 ;0 = high
BEQ CH1
DEC CUR_BYTE ;current htab
DEC BYTE_POS ;nibble index
CH1 RTS ;return to caller
* Change Byte for Left Arrow ---------------------------*
LARROW JSR CH_POS ;chk to affirm high
LDA CUR_BYTE ;current htab
CMP #$06
BEQ LA2
DEC BYTE_NO ;bufr.index
DEC CUR_BYTE ;current htab
DEC CUR_BYTE
DEC CUR_BYTE
DEC ASK_POS ;ascii grid index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
LA2 LDA #$33
STA CUR_BYTE ;current htab
LDA BYTE_NO ;bufr.index
CLC
ADC #$0F ;bump by 16 bytes
STA BYTE_NO ;bufr.index
LDA #$48
STA ASK_POS ;ascii grid index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
* Change Byte for Right Arrow --------------------------*
RARROW JSR CH_POS ;chk to affirm high
LDA CUR_BYTE ;current htab
CMP #$33
BEQ RA2
INC BYTE_NO ;bufr.index
INC CUR_BYTE ;current htab
INC CUR_BYTE
INC CUR_BYTE
INC ASK_POS ;ascii grid index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
RA2 LDA #$06
STA CUR_BYTE ;current htab
LDA BYTE_NO ;bufr.index
SEC
SBC #$0F ;bump back 16 bytes
STA BYTE_NO ;bufr.index
LDA #$39
STA ASK_POS ;ascii grid index
JSR UPD_POS ;update curs.pos.
RTS ;return to edit2
* Change Position in Byte ------------------------------*
SPCBAR LDA BYTE_POS ;nibble index
CMP #$00 ;is it high nibble
BEQ HINIB
DEC CUR_BYTE ;current htab
DEC BYTE_POS ;nibble index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
HINIB INC CUR_BYTE ;current htab
INC BYTE_POS ;nibble index
JSR UPD_POS ;update curs.pos.
RTS ;return to caller
* Update Cursor Position -------------------------------*
UPD_POS STA TEMPA ;save regs
LDA CUR_BYTE ;current htab
STA HORIZ ;set horiz.tab var
LDA CUR_LINE ;current vtab
STA VERT ;set vert.tab var.
JSR TAB ;pos.curs.using horiz.vert
LDA TEMPA ;restore regs.
RTS ;return to caller
* Print Block ------------------------------------------*
PRNTT LDA CSWL ;output hooks low
STA CSWLS ;save output hooks
LDA CSWH ;output hooks high
STA CSWHS ;save output hooks
LDA KSWL ;input hooks low
STA KSWLS ;save input hooks
LDA KSWH ;input hooks high
STA KSWHS ;save input hooks
LDA PAGE ;get current page index
STA PAGE_TMP ;store it
LDA #$16
STA VERT ;vert.tab var
LDA #$1D
STA HORIZ ;horiz.tab var
JSR TAB ;pos.curs.using vert.& horiz
LDX #$00 ;set base pntr
PRNT1 LDA PRNT_MSG,X ;string
JSR PCHAR ;char.output
CPX #$16 ;string terminate
BEQ PRNT2
INX ;bump pntr.
JMP PRNT1 ;get next char.
PRNT1A JMP PRNT_1
PRNT2 JSR READ1 ;read keyboard
CMP #$9B ;ESC
BEQ PRNT1A
AND #$DF ;mask to uppercase
CMP #$CE ;'N'
BEQ PRNT1A
CMP #$D9 ;'Y'
BEQ PRNT3
JMP PRNT2 ;get another key
PRNT3 JSR CLR1 ;clear message
LDA #$01 ;outport to printer
JSR OUTPORT ;set output hooks
LDX #$00 ;set base pntr.
BMSG LDA STR2A,X ;string
JSR PCHAR ;char.output
INX ;bump pntr.
CPX #$05 ;string terminate
BEQ BMSG1
JMP BMSG
BMSG1 LDA #$A0 ;space
JSR PCHAR ;char.output
LDA #$A4 ;'$'
JSR PCHAR ;char.output
LDA BLK_HIGH ;high order byte of block
JSR PHEX ;hex.output
LDA BLK_LOW ;low order byte of block
JSR PHEX ;hex.output
LDA #$8D ;crlf.
JSR PCHAR ;char.output
LDA #$05
STA NUM ;#of'='s for line
JSR LINE ;print (======)
LDX #$00 ;counter
PR LDA #$FC ;'|'
JSR PCHAR ;char.output
CPX #$10
BEQ PR1
TXA
JSR PHEX ;hex.output
INX ;bump counter
JMP PR ;get next indx
PR1 LDA #$05
STA NUM ;#of'='s for line
JSR LINE ;print (======)
LDX #$00 ;set base pntr.
PR2 LDA STR2,X ;string
JSR PCHAR ;char.output
CPX #$0B
BEQ PR3
INX ;bump pntr
JMP PR2 ;get next char.
PR3 LDA #$07
STA NUM ;#of'='s for line
JSR LINE ;print (======)
LDA #$00 ;set page 1
STA PAGE ;page index
LDA #$8D ;crlf.
JSR PCHAR ;char.output
LDA #$4E
STA NUM ;#of'='s for line
JSR LINE ;print (======)
LDA #$8D ;crlf.
JSR PCHAR ;char.output
JSR OUTPRN ;output to printer entry point
LDA #$8D ;crlf.
JSR PCHAR ;char.output
LDA #$01 ;set page 2
STA PAGE ;page index
JSR OUTPRN ;output to printer entry point
LDA #$8D ;crlf.
JSR PCHAR ;used to flush printer buff.
LDA CSWLS ;restore output hooks low
STA CSWL
LDA CSWHS ;restore output hooks high
STA CSWH
LDA KSWLS ;restore input hooks low
STA KSWL
LDA KSWHS ;restore input hooks high
STA KSWH
PRNT_1 JSR CLR1 ;clear message
LDA PAGE_TMP ;reset page index
STA PAGE ;page index
RTS ;return to caller
* Write Block ------------------------------------------*
RITE LDA #$16
STA VERT ;set vert.tab var.
LDA #$1C
STA HORIZ ;set horiz.tab var.
JSR TAB ;pos.curs.using vert.& horiz.
LDY #$00 ;set base pntr.
R LDA VMSG1,Y ;string
CMP #$00 ;string terminate
BEQ R1
JSR PCHAR ;char.output
INY ;bump pntr.
JMP R ;get next char.
R1 JSR READ1 ;read keyboard
AND #$DF ;mask to uppercase
CMP #$D9 ;'Y'
BEQ R2
JSR CLR1 ;go clear message
RTS ;return to caller
R2 JSR CLR1 ;go clear message
LDA #$81 ;write attribute
STA R_W ;read/write parameter
JSR MLI_E ;MLI entry point
LDA #$80 ;read attribute
STA R_W ;read/write parameter
RTS ;return to caller
CLR1 LDA #$16
STA VERT ;set vert.tab var.
LDA #$01
STA HORIZ ;set horiz.tab var.
JSR TAB ;pos.curs.using vert.& horiz.
JSR CLEOL ;clear to end of line
RTS ;return to caller
* Reset Base Block -------------------------------------*
RBAS JSR DEVICE ;get new base
JSR DISP_BLK ;disply block
RTS ;return to caller
* Last Block -------------------------------------------*
LSTBLK LDA BLK_LOW ;get low order byte of blk
CMP #$00 ;if $00 then set blk_low to
BEQ LB1 ;$FF and decrement blk_high
DEC BLK_LOW
JMP NBL ;get block
LB1 LDA #$FF
STA BLK_LOW ;set low order
DEC BLK_HIGH ;set high order
JMP NBL ;get block
* Change Page ------------------------------------------*
CHPAGE LDA PAGE ;page index
CMP #$00 ;page 1
BEQ P2
LDA #$00 ;set page 1
STA PAGE ;page index
JSR DISP_BLK ;display page
RTS ;return to caller
P2 LDA #$01 ;set page 2
STA PAGE ;page index
JSR DISP_BLK ;display page
RTS ;return to caller
* Get Next Block ---------------------------------------*
NBLKA LDA BLK_LOW ;get low order byte
CMP #$FF ;bump it by one
BEQ NCHK ;if $FF reset to $00
INC BLK_LOW
JMP NBL ;get block
NCHK LDA #$00 ;get high order byte
STA BLK_LOW ;bump it by one
INC BLK_HIGH
JMP NBL ;get block
* Get Block From Disk ----------------------------------*
NBL JSR MLI_E ;get block from disk
LDA #$00
STA PAGE ;reset page to 1
JSR DISP_BLK ;display block
RTS ;return to caller
* Print "="s Routine -----------------------------------*
LINE LDY #$00 ;initialize counter
LDA #$3D ;char "="
L1 JSR PCHAR ;char.ouput
INY ;bump counter
CPY NUM ;#of'='s to print
BEQ RET1
JMP L1 ;loop until cmplt
RET1 RTS ;return to caller
* Get Device Info --------------------------------------*
INPUT1 CPY #$01
BEQ DRV ;get drive number
CPY #$02
BEQ SLT ;get slot number
JMP BLK ;get block number
DRV STY TEMPY ;save 'Y' reg.
JSR READ1 ;read keyboard
CMP #$B1 ;'1'
BCC DRVER ;below range
CMP #$B3 ;'3'
BCS DRVER ;above range
LDY TEMPY ;restore 'Y' reg.
SBC #$AF ;mask to hex equiv.
CMP #$01 ;is it drive one
BEQ SET1
JSR PHEX ;hex.output
LDX #$80 ;setup dev_num Drive 2
STX DEV_NUM
RTS ;return to caller
DRVER PLA ;error in input restore stack
PLA
JMP DEVICE ;try again
SET1 JSR PHEX ;hex.output
LDX #$00 ;setup dev_num Drive 1
STX DEV_NUM
RTS ;return to caller
SLT STY TEMPY ;save 'Y' reg.
DRVR JSR READ1 ;read keyboard
CMP #$9B ;ESC
BEQ DRVR
CMP #$B0 ;'0'
BCC DRVR ;below range
CMP #$B8 ;'8'
BCS DRVR ;above range
LDY TEMPY ;restore 'Y' reg.
SBC #$AF ;mask to hex equiv.
JSR PHEX ;hex.output
ASL ;shift in to slot pos.
ASL
ASL
ASL
CLC ;clear carry
ADC DEV_NUM ;set up bit pattern for-
STA DEV_NUM ;-dev_num
RTS ;return to caller
BLKER PLA ;error in input restore stack
PLA
JMP DEVICE ;try again
BLK LDX #$00 ;initialize pointer
BLK1 JSR READ1 ;read keyboard
CMP #$9B ;ESC
BEQ BLKER ;ERROR in input
CMP #$B0 ;less than 0
BCC BLK2
CMP #$BA ;greater than 9
BCS BLK3
JSR PCHAR ;char.output
AND #$0F ;mask off high nibble
STA FIRST,X ;store in place holders
INX ;bump pntr.
CPX #$04 ;end input after the 4th char.
BEQ BLKD
BLK2 JMP BLK1 ;loop until cmplt.
BLK3 AND #$DF ;mask to uppercase
CMP #$C1 ;less than 'A'
BCC BLK2
CMP #$C7 ;greater than 'F'
BCS BLK2
JSR PCHAR ;char.output
AND #$0F ;mask off high nibble
CLC
ADC #$09 ;convert to hex equiv.
STA FIRST,X ;store in place holder
INX ;bump pntr.
CPX #$04 ;end input after 4th char.
BEQ BLKD
JMP BLK1 ;loop until cmplt
BLKD LDA FIRST ;get first place holder
ASL ;shift to high nibble
ASL
ASL
ASL
CLC
ADC SECOND ;add to second place holder
STA BLK_HIGH ;high order byte of block
LDA THIRD ;get third place holder
ASL ;shift to high nibble
ASL
ASL
ASL
CLC
ADC FOURTH ;add to fourth place holder
STA BLK_LOW ;low order byte of block
RTS ;return to caller
* Set up for MLI Entry Point -------------------------*
MLI_E JSR MLI ;MLI entry point
R_W DB #$00 ;read/write parameter
DA FCB ;file control block
BCS ERROR ;error routine
RTS ;return to caller
* Error Routine for READ or WRITE ----------------------*
ERROR STA TEMPA ;save 'A' reg.
LDA #$06
STA HORIZ ;horiz.tab var.
STA VERT ;vert.tab var.
JSR TAB ;pos.curs.using vert.& horiz.
JSR HOME ;clear screen
LDA TEMPA ;restore 'A' reg.
CLC ;clear error flag
CMP #$28 ;NO DEVICE
BEQ NO_DEV
LDX #$00 ;base pntr.
E1 LDA ERR_MSG1,X ;string
CMP #$00 ;string terminate
BEQ E2A
JSR PCHAR ;char.output
INX ;bump pntr.
JMP E1 ;get next char.
E2A LDX #$00 ;base pntr.
E2AA LDA TRY_MSG,X ;string
CMP #$00 ;string terminate
BEQ E2B
JSR PCHAR ;char.output
INX ;bump pntr.
JMP E2AA ;get next char.
E2B JSR READ1 ;read keyboard
CMP #$9B ;'ESC'
BEQ E2C
AND #$DF ;mask to uppercase
CMP #$D9 ;'Y'
BEQ E2C
CMP #$CE ;'N'
BEQ OUT
JMP E2B ;get another key
OUT JSR QT ;if NO exit program
E2C JMP DEVICE ;get new input
NO_DEV LDX #$00 ;set base pntr.
E3 LDA ERR_MSG2,X ;string
CMP #$00 ;string terminate
BEQ E4
JSR PCHAR ;char.output
INX ;bump pntr.
JMP E3 ;get next char.
E4 JMP E2A ;try again
* Quit Routine -----------------------------------------*
QT LDA #$16
STA VERT ;vert.tab var.
LDA #$1C
STA HORIZ ;horiz.tab var.
JSR TAB ;pos.curs.using vert.& horiz.
LDX #$00 ;set base pntr.
QT1 LDA QT_MSG,X ;string
CMP #$00 ;string terminate
BEQ QT2
JSR PCHAR ;char.output
INX ;bump pntr.
JMP QT1 ;get next char.
QT2 JSR READ1 ;read keyboard
CMP #$9B ;'ESC'
BEQ QT3
AND #$DF ;mask to uppercase
CMP #$D9 ;'Y'
BEQ QT4
CMP #$CE ;'N'
BEQ QT3
JMP QT2 ;must be 'Y','N','ESC'
QT3 JSR CLR1 ;clear message
RTS ;return to caller
QT4 PLA ;restore stack
PLA
QUIT LDA #$00 ;open entire screen
STA TOP ;top margin
LDA #$17
STA BOTTOM ;bottom margin
LDA #$50
STA RIGHT ;right margin
JSR HOME ;clear screen
JMP BASIC ;return to basic prompt
* Display Block Routine --------------------------------*
DISP_BLK LDA #$50
STA RIGHT ;right margin
LDA #$05
STA VERT ;vert.tab var.
LDA #$4B
STA HORIZ ;horiz.tab var.
JSR TAB ;pos.curs.using vert.& horiz.
LDA #$A4 ;'$'
JSR PCHAR ;char.output
LDA BLK_HIGH ;high order byte of block
JSR PHEX ;hex.output
LDA BLK_LOW ;low order byte of block
JSR PHEX ;hex.output
LDA #$4B
STA RIGHT ;right margin
LDA #$06
STA VERT ;vert.tab var.
LDA #$00
STA HORIZ ;horiz.tab var.
JSR TAB ;pos.curs.using vert.& horiz.
JSR HOME ;clear screen
OUTPRN LDA #$0F
STA EBASE ;line end..base pntr
LDX #$00 ;pointer
LDY #$00 ;pointer
DIS1 LDA PAGE ;either $00 or $01
JSR PHEX ;hex.output
TYA ;line number
JSR PHEX ;hex.ouput
LDA #$7C ;'|'
JSR PCHAR ;char.output
LDA #$3E ;'>'
JSR PCHAR ;char.output
DIS2 LDA PAGE ;
CMP #$00 ;page 1
BEQ DIS2A ;is page 1
LDA BBUFF2,X ;get byte from page 2
JMP DIS2B
DIS2A LDA BBUFF,X ;get byte from page 1
DIS2B JSR PHEX ;hex.ouput
LDA #$A0 ;space
CPX EBASE ;line end..base pntr.
BEQ DIS3
JSR PCHAR ;char.output
INX ;bump index
JMP DIS2 ;get next byte
DIS3 STX BPNTR ;base pntr for new line
LDA #$7C ;'|'
JSR PCHAR ;char.output
LDA #$A0 ;space
JSR PCHAR ;char.output
JSR PCHAR
LDA #$7C ;'|'
JSR PCHAR
TXA ;reset byte counter to 1st
SEC ;byte in line and print
SBC #$0F ;corresponding ascii
TAX
DIS4 LDA PAGE ;page index
CMP #$00 ;page 1
BEQ DIS4A ;is page 1
LDA BBUFF2,X ;get byte from page 2
JMP DIS4B
DIS4A LDA BBUFF,X ;get byte from page 1
DIS4B CMP #$21 ;low range ascii
BCC PERIOD ;out of range go print '.'
CMP #$7F ;high range ascii
BCS PERIOD ;out of range go print '.'
JMP DIS5
PERIOD LDA #$AE ;'.'
JSR PCHAR ;char.output
CPX BPNTR ;base pointer < EOL
BEQ DIS6 ;is last char in line
INX ;bump index
JMP DIS4 ;get next byte
DIS5 ORA #$80 ;flip to high ascii
JSR PCHAR ;char.output
CPX BPNTR ;base pointer < EOL
BEQ DIS6 ;is last char in line
INX ;bump index
JMP DIS4 ;get next byte
DIS6 LDX BPNTR ;base pointer line begin
CPX #$FF ;end of page
BEQ DIS7
LDA #$7C ;'|'
JSR PCHAR ;char.output
LDA #$8D ;crlf
JSR PCHAR ;char.output
TYA
ADC #$10 ;bump line #
TAY
INX
TXA
ADC #$0F ;bump by 16
STA EBASE ;line end..base pntr.
JMP DIS1 ;loop next line
DIS7 LDA #$7C ;'|'
JSR PCHAR ;char.output
RTS ;return to caller
*-------------------------------------------------------*
END